home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / c / compres.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  4.8 KB  |  224 lines

  1. code    segment
  2.  
  3.         assume  cs:code, ds:code, es:code
  4.  
  5.         org     100h
  6.  
  7. prog:
  8.  
  9.         jmp     main
  10.  
  11.  
  12.  
  13. tbl     dw      256 dup (0)
  14.  
  15. asc     db      256 dup (0)
  16.  
  17. cod     db      256 dup (0)
  18.  
  19. len     db      256 dup (0)
  20.  
  21. dat     db      0,10,16,9,64,8,64,8,0,7
  22.  
  23. fn1     db      'afd.com',0
  24.  
  25. fn2     db      'sup.com',0
  26.  
  27. fn3     db      'e1.com',0
  28.  
  29.  
  30.  
  31. main:
  32.  
  33.  
  34.  
  35.         call    read
  36.  
  37.         call    build
  38.  
  39.         call    uha
  40.  
  41.         call    good
  42.  
  43.         call    write
  44.  
  45.  
  46.  
  47.         mov     al,00h
  48.  
  49.         mov     ah,4ch
  50.  
  51.         int     21h
  52.  
  53.  
  54.  
  55. good    proc    near
  56.  
  57.         mov     ax,cs
  58.  
  59.         mov     ds,ax
  60.  
  61.         mov     si,offset asc
  62.  
  63.         mov     di,152
  64.  
  65.         mov     cx,256
  66.  
  67.         rep     movsb
  68.  
  69.  
  70.  
  71.         mov     dx,offset fn3
  72.  
  73.         mov     al,00h
  74.  
  75.         mov     ah,3dh
  76.  
  77.         int     21h
  78.  
  79.         jc      ssr
  80.  
  81.         mov     bx,ax
  82.  
  83.         mov     ax,es
  84.  
  85.         mov     ds,ax
  86.  
  87.         sub     dx,dx
  88.  
  89.         mov     cx,152
  90.  
  91.         mov     ah,3fh
  92.  
  93.         int     21h
  94.  
  95.         jc      ssr
  96.  
  97.         mov     ah,3eh
  98.  
  99.         int     21h
  100.  
  101.         mov     ax,cs
  102.  
  103.         mov     ds,ax
  104.  
  105. ssr:    ret
  106.  
  107. good    endp
  108.  
  109.  
  110.  
  111. uha     proc    near
  112.  
  113.         mov     ax,cs
  114.  
  115.         add     ax,1000h
  116.  
  117.         mov     ds,ax
  118.  
  119.         add     ax,1000h
  120.  
  121.         mov     es,ax
  122.  
  123.         mov     bx,4fffh
  124.  
  125.         mov     di,bx
  126.  
  127.         mov     ch,0
  128.  
  129.         sub     bp,bp
  130.  
  131. lu10:   sub     ax,ax
  132.  
  133.         mov     al,[bx]
  134.  
  135.         mov     si,ax
  136.  
  137.         mov     al,cs:cod[si]
  138.  
  139.         mov     dl,cs:len[si]
  140.  
  141.         mov     cl,dl
  142.  
  143.         cmp     dl,7
  144.  
  145.         jne     lu20
  146.  
  147.         inc     ah
  148.  
  149. lu20:   sub     cl,ch
  150.  
  151.         shl     ax,cl
  152.  
  153.         or      bp,ax
  154.  
  155.         add     ch,16
  156.  
  157.         sub     ch,dl
  158.  
  159.         mov     cl,8
  160.  
  161. lu30:   cmp     ch,cl
  162.  
  163.         jc      lu40
  164.  
  165.         mov     ax,bp
  166.  
  167.         shl     bp,cl
  168.  
  169.         mov     es:[di],ah
  170.  
  171.         dec     di
  172.  
  173.         sub     ch,cl
  174.  
  175.         jmp     short lu30
  176.  
  177. lu40:   dec     bx
  178.  
  179.         cmp     bx,0ffffh
  180.  
  181.         jne     lu10
  182.  
  183.         mov     ax,bp
  184.  
  185.         mov     es:[di],ah
  186.  
  187.         ret
  188.  
  189. uha     endp
  190.  
  191.  
  192.  
  193. fill    proc    near
  194.  
  195.         sub     si,si
  196.  
  197.         mov     cx,0100h
  198.  
  199. lf10:   mov     ax,si
  200.  
  201.         mov     cs:asc[si],al
  202.  
  203.         inc     si
  204.  
  205.         loop    lf10
  206.  
  207.         sub     bx,bx
  208.  
  209.         mov     cx,5000h
  210.  
  211. lf20:   mov     al,[bx]
  212.  
  213.         mov     si,ax
  214.  
  215.         shl     si,1
  216.  
  217.         inc     cs:tbl[si]
  218.  
  219.         inc     bx
  220.  
  221.         loop    lf20
  222.  
  223.         ret
  224.  
  225. fill    endp
  226.  
  227.  
  228.  
  229. pause   proc    near
  230.  
  231.         push    ax
  232.  
  233.         mov     ah,01h
  234.  
  235.         int     21h
  236.  
  237.         pop     ax
  238.  
  239.         ret
  240.  
  241. pause   endp
  242.  
  243.  
  244.  
  245. sort    proc    near
  246.  
  247.         mov     cx,00ffh
  248.  
  249. l10:    mov     di,cx
  250.  
  251.         mov     bx,cx
  252.  
  253.         shl     bx,1
  254.  
  255.         add     bx,offset tbl
  256.  
  257.         sub     ax,ax
  258.  
  259. l20:    mov     si,ax
  260.  
  261.         shl     si,1
  262.  
  263.         mov     dx,tbl[si]
  264.  
  265.         cmp     dx,[bx]
  266.  
  267.         jnc     l30
  268.  
  269.         xchg    dx,[bx]
  270.  
  271.         xchg    dx,tbl[si]
  272.  
  273.         shr     si,1
  274.  
  275.         mov     dl,asc[si]
  276.  
  277.         xchg    dl,asc[di]
  278.  
  279.         xchg    dl,asc[si]
  280.  
  281. l30:    inc     ax
  282.  
  283.         cmp     ax,cx
  284.  
  285.         jc      l20
  286.  
  287.         loop    l10
  288.  
  289.         ret
  290.  
  291. sort    endp
  292.  
  293.  
  294.  
  295. make    proc    near
  296.  
  297.         mov     cx,16
  298.  
  299.         mov     bx,offset dat
  300.  
  301.         sub     si,si
  302.  
  303.         sub     ax,ax
  304.  
  305. lm10:   mov     al,asc[si]
  306.  
  307.         mov     di,ax
  308.  
  309.         mov     dx,si
  310.  
  311.         add     dl,[bx]
  312.  
  313.         mov     cod[di],dl
  314.  
  315.         mov     dl,[bx+1]
  316.  
  317.         mov     len[di],dl
  318.  
  319.         inc     si
  320.  
  321.         cmp     si,cx
  322.  
  323.         jnz     lm10
  324.  
  325.         inc     bx
  326.  
  327.         inc     bx
  328.  
  329.         shl     cx,1
  330.  
  331.         cmp     cx,512
  332.  
  333.         jnz     lm10
  334.  
  335.         ret
  336.  
  337. make    endp
  338.  
  339.  
  340.  
  341. build   proc    near
  342.  
  343.         call    fill
  344.  
  345.         mov     ax,cs
  346.  
  347.         mov     ds,ax
  348.  
  349.         call    sort
  350.  
  351.         call    make
  352.  
  353.         ret
  354.  
  355. build   endp
  356.  
  357.  
  358.  
  359. write   proc    near
  360.  
  361.         mov     dx,offset fn2
  362.  
  363.         mov     al,02h
  364.  
  365.         mov     ah,3dh
  366.  
  367.         int     21h
  368.  
  369.         jc      sw
  370.  
  371.         mov     bx,ax
  372.  
  373.         mov     ax,es
  374.  
  375.         mov     ds,ax
  376.  
  377.         sub     dx,dx
  378.  
  379.         mov     cx,5000h
  380.  
  381.         mov     ah,40h
  382.  
  383.         int     21h
  384.  
  385.         jc      sw
  386.  
  387.         mov     ah,3eh
  388.  
  389.         int     21h
  390.  
  391. sw:     ret
  392.  
  393. write   endp
  394.  
  395.  
  396.  
  397. read    proc    near
  398.  
  399.         mov     dx,offset fn1
  400.  
  401.         mov     al,00h
  402.  
  403.         mov     ah,3dh
  404.  
  405.         int     21h
  406.  
  407.         jc      sr
  408.  
  409.         mov     bx,ax
  410.  
  411.         mov     ax,ds
  412.  
  413.         add     ax,1000h
  414.  
  415.         mov     ds,ax
  416.  
  417.         sub     dx,dx
  418.  
  419.         mov     cx,5000h
  420.  
  421.         mov     ah,3fh
  422.  
  423.         int     21h
  424.  
  425.         jc      sr
  426.  
  427.         mov     ah,3eh
  428.  
  429.         int     21h
  430.  
  431. sr:     ret
  432.  
  433. read    endp
  434.  
  435.  
  436.  
  437.  
  438.  
  439. last    label   byte
  440.  
  441. code    ends
  442.  
  443.         end     prog
  444.  
  445.  
  446.  
  447.